package com.jhinwins.equipmenteb.equipmentebserver.dao;

import com.jhinwins.equipmenteb.equipmentebserver.entity.OrderBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface OrderDao extends JpaRepository<OrderBean, Long> {
    /**
     * 更新订单状态
     */
    @Modifying
    @Query("update com.jhinwins.equipmenteb.equipmentebserver.entity.OrderBean set state=:newState where id in (:ids)")
    int updateOrderState(@Param("ids") List<Long> ids, @Param("newState") String newState);

    /**
     * 更新订单地址
     */
    @Modifying
    @Query("update com.jhinwins.equipmenteb.equipmentebserver.entity.OrderBean set address=:newAddress where id in (:ids)")
    int updateOrderAddr(@Param("ids") List<Long> ids, @Param("newAddress") String newAddress);
}
